package cn.javabb.core.service.sys;

import cn.hutool.core.util.StrUtil;
import cn.javabb.core.base.BaseService;
import cn.javabb.core.entity.sys.LogDO;
import cn.javabb.core.query.LogQuery;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

/**
 * @Author QINB imqinbao@163.com
 * @CreateDate 2018/11/5/005 16:11
 * @Since V1.0
 */
@Service
public class LogService extends BaseService<LogDO> {

    /**
     * 获取列表
     * @param query
     * @return
     */
    public Page<?> list(LogQuery query){
        Page<?> p = PageHelper.startPage(query.getPage(),query.getSize());
        Example ex = new Example(LogDO.class);
        if (null != query.getStartDate() && null != query.getEndDate()) {
            ex.createCriteria().andBetween("createTime",query.getStartDate(),query.getEndDate());
        }
        if (StrUtil.isNotBlank(query.getOperName())) {
            ex.createCriteria().andLike("operName","%"+query.getOperName()+"%");
        }
        if (null != query.getType()) {
            ex.createCriteria().andEqualTo("type", query.getType());
        }
        ex.orderBy("createTime").desc();
        this.queryListByExample(ex);
        return p;
    }

}
